package com.ftg.learn.day08;

import java.util.UUID;

/**
 * 练习题
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/7/25 下午3:19
 */
public class HomeWork02 {

//    给定一个长度,随机产生一个该长度的字符串,由大写,小写字母

    public static String question01() {
        StringBuilder stringBuilder = new StringBuilder();

        char[] cs = new char[]{'a', 'b', 'c', 'd'};
        for (int i = 0; i < 26; i++) {
            int a = (int) (Math.random() * cs.length);
            stringBuilder.append(cs[a]);
        }
        return stringBuilder.toString();
    }

    public static String question01_1() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 13; i++) {
            int flag = (int) (Math.random() * 2);
            char c;
            if (flag == 0) {
                //小写
                c = (char) ((int) (Math.random() * 26) + 65);
            } else {
                //大写
                c = (char) ((int) (Math.random() * 26) + 97);
            }

            stringBuilder.append(c);
        }

        return stringBuilder.toString();
    }

    public static String question01_2() {
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            int flag = (int) (Math.random() * 2);
            char c = (char) ((flag == 0 ? 97 : 65) + (int) (Math.random() * 26));
            stringBuilder.append(c);
        }
        return stringBuilder.toString();
    }

    public static String testUuid() {
        System.out.println(UUID.randomUUID());
        return UUID.randomUUID().toString();
    }

    public static void main(String[] args) {
//        System.out.println(question01());
//        System.out.println(question01_1());
        System.out.println(question01_2());
    }

}
